import%20marimo%0A%0A__generated_with%20%3D%20%220.12.2%22%0Aapp%20%3D%20marimo.App(width%3D%22medium%22)%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20import%20marimo%20as%20mo%0A%20%20%20%20return%20(mo%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(%0A%20%20%20%20%20%20%20%20%22%22%22%0A%20%20%20%20%20%20%20%20%23%23%23%3Cspan%20style%3D%22color%3A%20brown%22%3EProject%20Overview%3C%2Fspan%3E%20%0A%0A%20%20%20%20%20%20%20%20We%20analyze%20gene%20expression%20patterns%20in%20breast%20tissue%20samples%20to%20identify%20differentially%20expressed%20genes%20associated%20with%20early-stage%20breast%20cancer%20and%20to%20study%20cancer%20progression.%20Our%20goal%20is%20to%20develop%20a%20predictive%20model%20that%20accurately%20assesses%20breast%20cancer%20prognosis%2C%20improving%20early%20detection%20and%20treatment%20planning.%22%0A%20%20%20%20%20%20%20%20Lot%20of%20early%20research%20paper%20were%20sujesting%20using%20models%20such%20as%20HMM%20how%20ever%20these%20models%20are%20Require%20pre-selected%20features%20(e.g.%2C%20from%20AHP-based%20ranking).%20May%20miss%20complex%20interactions%20between%20genes%20because%20they%20rely%20on%20predefined%20relationships.%20Thus%20we%20decided%20to%20use%20deep%20learning%20approach%20to%20be%20able%20to%20create%20a%20robust%20model%20for%20subtype%20classificatino%20and%20also%20assist%20us%20with%20prognosis%20studies.%20We%20migh%20still%20use%20ahp%20analysis%20for%20some%20side%20edas.%20as%20well%20as%20corolation%20analysis%20on%20clinical%20variables%20helping%20furthur%20diganosis.%0A%20%20%20%20%20%20%20%20%22%22%22%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(%0A%20%20%20%20%20%20%20%20%22%22%22%0A%20%20%20%20%20%20%20%20%23%23%23%20%3Cspan%20style%3D%22color%3A%20brown%22%3EVisually%20see%20the%20top%20300%20Genes%20in%20the%20Healthy%20samples%20dataset!%0A%0A%20%20%20%20%20%20%20%20Now%20lets%20see%20what%20are%20the%20most%20exressed%20genes%20in%20the%20BRCA%20genes.%20The%20mean%20expression%20for%20all%20the%20genes%20is%20selcted%20and%20following%20chart%20is%20showing%20the%20top%20300%20genes%20that%20had%20highes%20mean.%0A%0A%20%20%20%20%20%20%20%20**Note%3A**%20Even%20the%20genes%20has%20the%20most%20variations%20posses%20importance%20but%20this%20is%20not%20best%20way%20to%20calculate%20that.%20Instead%20we%20are%20going%20to%20use%20AHP%20analysis%20to%20rank%20the%20genes%20and%20analyze%20that%20more%20accurately.%0A%20%20%20%20%20%20%20%20%22%22%22%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20import%20pandas%20as%20pd%0A%20%20%20%20import%20plotly.express%20as%20px%0A%0A%20%20%20%20%23%20healthy_dataSet%20%3D%20pd.read_csv(%22..%2F..%2Fdata%2FModelDataSets%2FhelthyExpressions.csv%22)%0A%20%20%20%20%23%20healthy_dataSet.set_index(healthy_dataSet.columns%5B0%5D%2C%20inplace%3DTrue)%0A%20%20%20%20healthy_dataSet%20%3D%20pd.read_csv(%0A%20%20%20%20%20%20%20%20'.%2Fdata%2FhelthyExpressions.csv'%2C%20sep%3D%22%2C%22%2C%20index_col%3D0%0A%20%20%20%20)%0A%20%20%20%20%23%20healthy_dataSet.set_index(healthy_dataSet.columns%5B0%5D%2C%20inplace%3DTrue)%0A%20%20%20%20%23%20Extract%20genes%20and%20compute%20mean%20expression%0A%20%20%20%20genes%20%3D%20healthy_dataSet.columns%0A%20%20%20%20average%20%3D%20healthy_dataSet.mean(axis%3D0)%20%20%23%20Compute%20mean%20across%20all%20samples%0A%0A%20%20%20%20%23%20Create%20a%20new%20DataFrame%20with%20gene%20names%20and%20their%20average%20expression%0A%20%20%20%20plot_df%20%3D%20pd.DataFrame(%7B%22Genes%22%3A%20genes%2C%20%22avg_expr_level%22%3A%20average%7D)%0A%0A%20%20%20%20%23%20Sort%20and%20select%20the%20top%20300%20genes%20by%20expression%20level%0A%20%20%20%20plot_df%20%3D%20plot_df.sort_values(by%3D%22avg_expr_level%22%2C%20ascending%3DFalse).iloc%5B%3A300%5D%0A%0A%20%20%20%20%23%20Create%20an%20interactive%20bar%20plot%0A%20%20%20%20fig%20%3D%20mo.ui.plotly(%0A%20%20%20%20%20%20%20%20px.bar(%0A%20%20%20%20%20%20%20%20%20%20%20%20plot_df%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20x%3D%22Genes%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20y%3D%22avg_expr_level%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20title%3D%22Gene%20Expression%20Visualization%20for%20Top%20300%20Genes%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20labels%3D%7B%22avg_expr_level%22%3A%20%22Mean%20Expression%20Level%22%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22avg_expr_level%22%2C%20%20%23%20Optional%3A%20color%20for%20better%20visualization%0A%20%20%20%20%20%20%20%20).update_layout(xaxis_tickangle%3D-45)%0A%20%20%20%20)%0A%0A%20%20%20%20%23%20Rotate%20x-axis%20labels%20for%20better%20visibility%0A%20%20%20%20mo.ui.tabs(%7B%22Visually%22%3A%20fig%2C%20%22Related_Data%22%3A%20mo.ui.table(healthy_dataSet)%7D)%0A%20%20%20%20return%20average%2C%20fig%2C%20genes%2C%20healthy_dataSet%2C%20pd%2C%20plot_df%2C%20px%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo%2C%20pd%2C%20plot_df%2C%20px)%3A%0A%20%20%20%20%23%20cancer_dataSet%20%3D%20pd.read_csv(%22..%2F..%2Fdata%2FModelDataSets%2FcancerExpressions.csv%22)%0A%20%20%20%20cancer_dataSet%20%3D%20pd.read_csv('.%2Fdata%2FcancerExpressions.csv')%0A%20%20%20%20plot_genes%20%3D%20plot_df%5B%22Genes%22%5D.tolist()%0A%20%20%20%20average2%20%3D%20cancer_dataSet%5Bplot_genes%5D.mean(axis%3D0)%0A%20%20%20%20plot2_df%20%3D%20pd.DataFrame(%7B%22Genes%22%3A%20plot_genes%2C%20%22avg_expr_level%22%3A%20average2%7D)%0A%20%20%20%20fig2%20%3D%20mo.ui.plotly(%0A%20%20%20%20%20%20%20%20px.bar(%0A%20%20%20%20%20%20%20%20%20%20%20%20plot2_df%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20x%3D%22Genes%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20y%3D%22avg_expr_level%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20title%3D%22Gene%20Expression%20Visualization%20for%20Top%20300%20Genes%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20labels%3D%7B%22avg_expr_level%22%3A%20%22Mean%20Expression%20Level%22%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22avg_expr_level%22%2C%20%20%23%20Optional%3A%20color%20for%20better%20visualization%0A%20%20%20%20%20%20%20%20).update_layout(xaxis_tickangle%3D-45)%0A%20%20%20%20)%0A%0A%20%20%20%20%23%20Rotate%20x-axis%20labels%20for%20better%20visibility%0A%20%20%20%20mo.ui.tabs(%7B%22Visualization%22%3A%20fig2%2C%20%22Relted_Data%22%3A%20mo.ui.table(plot2_df)%7D)%0A%20%20%20%20return%20average2%2C%20cancer_dataSet%2C%20fig2%2C%20plot2_df%2C%20plot_genes%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(%0A%20%20%20%20%20%20%20%20%22%22%22%0A%20%20%20%20%20%20%20%20%23%23%3Cspan%20style%3D%22color%3A%20brown%22%3EAnalysis%20of%20biomarkers%20of%20breast%20cancers%20usting%20AHP%3C%2Fspan%3E%0A%0A%20%20%20%20%20%20%20%20**The%20Cancer%20Biomarkers**%20are%20biological%20molecules%20that%20indicate%20the%20presence%20of%20cancer%20or%20abnormal%20cell%20processes.%20They%20can%20be%20found%20in%20blood%2C%20urine%2C%20tissue%2C%20or%20other%20bodily%20fluids.%20We%20are%20studying%20this%20by%20analysing%20the%20gene%20expressions%20of%20healthy%20and%20cancerous%20samples.%20To%20achive%20this%2C%20we%20are%20using%20%3Cspan%20style%3D%22color%3A%20green%22%3EAnalatical%20Hiracial%20Process%3C%2Fspan%3E.%20%0A%0A%20%20%20%20%20%20%20%20The%20Analytic%20Hierarchy%20Process%20(AHP)%20is%20a%20structured%20decision-making%20approach%20that%20helps%20prioritize%20and%20select%20the%20most%20important%20criteria%20in%20complex%20problems.%20It%20works%20by%20breaking%20a%20problem%20into%20a%20hierarchy%20of%20criteria%20and%20sub-criteria%2C%20assigning%20numerical%20values%20to%20their%20relative%20importance%2C%20and%20using%20pairwise%20comparisons%20to%20generate%20a%20weighted%20ranking.%20Traditional%20AHP%20is%20often%20qualitative%2C%20relying%20on%20expert%20judgment%2C%20but%20in%20bioinformatics%2C%20a%20modified%20AHP%20can%20integrate%20statistical%20methods%20to%20enhance%20objectivity.%0A%0A%0A%20%20%20%20%20%20%20%20In%20the%20context%20of%20biomarker%20analysis%20for%20BRCA-related%20research%2C%20AHP%20can%20significantly%20improve%20the%20selection%20of%20key%20biomarkers%20by%20aggregating%20multiple%20statistical%20gene%20selection%20methods.%20Instead%20of%20relying%20on%20a%20single%20metric%2C%20such%20as%20a%20t-test%20or%20entropy%2C%20the%20modified%20AHP%20integrates%20multiple%20ranking%20criteria%20(e.g.%2C%20Wilcoxon%20test%2C%20ROC%20curves%2C%20signal-to-noise%20ratio)%20to%20create%20a%20more%20stable%20and%20reliable%20subset%20of%20genes.%20This%20method%20ensures%20that%20the%20chosen%20biomarkers%20are%20not%20only%20statistically%20significant%20but%20also%20robust%20across%20different%20datasets%20and%20ranking%20approaches.%20By%20identifying%20the%20most%20influential%20genes%20systematically%2C%20AHP%20helps%20refine%20the%20list%20of%20biomarkers%20that%20could%20be%20further%20analyzed%20for%20their%20role%20in%20breast%20cancer%20progression%2C%20prognosis%2C%20or%20response%20to%20treatment.%0A%0A%20%20%20%20%20%20%20%20%3Cspan%20style%3D%22color%3A%20brown%22%3EModified%20AHP%3A%3C%2Fspan%3E%0A%0A%20%20%20%20%20%20%20%20*%20%3Cspan%20style%3D%22color%3A%20brown%22%3ETwo-Sample%20t-Test%3A%3C%2Fspan%3E%0A%0A%20%20%20%20%20%20%20%20Purpose%3A%20Identifies%20statistically%20significant%20differences%20in%20gene%20expression%20between%20two%20groups%20(e.g.%2C%20cancerous%20vs.%20healthy%20cells).%0A%0A%20%20%20%20%20%20%20%20Method%3A%20Compares%20the%20means%20of%20two%20independent%20samples%20using%20the%20t-statistic.%0A%0A%20%20%20%20%20%20%20%20Output%3A%20A%20t-score%20and%20p-value.%20A%20small%20p-value%20indicates%20significant%20differences%20in%20expression.%0A%0A%20%20%20%20%20%20%20%20*%20%3Cspan%20style%3D%22color%3A%20brown%22%3EEntropy%20Test%3A%3C%2Fspan%3E%0A%0A%20%20%20%20%20%20%20%20Purpose%3A%20Measures%20the%20disorder%20in%20gene%20expression%20levels.%0A%0A%20%20%20%20%20%20%20%20Method%3A%20Computes%20entropy%20using%20histogram-based%20probability%20distributions.%0A%0A%20%20%20%20%20%20%20%20Output%3A%20Higher%20entropy%20values%20indicate%20genes%20with%20more%20variability%2C%20which%20are%20more%20useful%20for%20classification.%0A%0A%20%20%20%20%20%20%20%20*%20%3Cspan%20style%3D%22color%3A%20brown%22%3EWilcoxon%20Rank-Sum%20Test%3A%3C%2Fspan%3E%0A%0A%20%20%20%20%20%20%20%20Purpose%3A%20A%20non-parametric%20test%20used%20to%20rank%20genes%20based%20on%20their%20median%20expression%20differences.%0A%0A%20%20%20%20%20%20%20%20Method%3A%20Compares%20the%20ranks%20of%20two%20independent%20samples%20instead%20of%20their%20means.%0A%0A%20%20%20%20%20%20%20%20Output%3A%20A%20Wilcoxon%20statistic%20and%20a%20p-value.%20A%20low%20p-value%20suggests%20significant%20differences%20in%20gene%20ranks.%0A%0A%20%20%20%20%20%20%20%20*%20%3Cspan%20style%3D%22color%3A%20brown%22%3ESignal-to-Noise%20Ratio%20(SNR)%3A%3C%2Fspan%3E%0A%0A%20%20%20%20%20%20%20%20Purpose%3A%20Compares%20the%20difference%20in%20mean%20expression%20levels%20relative%20to%20the%20standard%20deviation.%0A%0A%20%20%20%20%20%20%20%20Method%3A%20SNR%20is%20calculated%20as%20the%20difference%20between%20the%20means%20of%20two%20groups%20divided%20by%20the%20sum%20of%20their%20standard%20deviations.%0A%0A%20%20%20%20%20%20%20%20Output%3A%20A%20higher%20SNR%20suggests%20that%20the%20gene%20has%20a%20strong%20discriminatory%20power%20between%20groups.%0A%0A%20%20%20%20%20%20%20%20*%20%3Cspan%20style%3D%22color%3A%20brown%22%3EAHP%20Weighted%20Ranking%3A%3C%2Fspan%3E%0A%0A%20%20%20%20%20%20%20%20Purpose%3A%20Integrates%20statistical%20measures%20into%20a%20single%20weighted%20ranking%20system%20to%20prioritize%20significant%20genes.%0A%0A%20%20%20%20%20%20%20%20Method%3A%20Normalizes%20scores%20across%20all%20statistical%20tests%20and%20applies%20predefined%20weights.%0A%0A%20%20%20%20%20%20%20%20Output%3A%20A%20final%20ranking%20score%20indicating%20the%20importance%20of%20each%20gene%20in%20classification.%0A%0A%20%20%20%20%20%20%20%20*%20%3Cspan%20style%3D%22color%3A%20brown%22%3E%20Eigenvalues%20and%20Eigenvectors%20in%20Gene%20Selection%20(Modified%20AHP)%3A%20%3C%2Fspan%3E%0A%0A%20%20%20%20%20%20%20%20The%20modified%20Analytic%20Hierarchy%20Process%20(AHP)%20used%20for%20gene%20selection%20involves%20constructing%20a%20pairwise%20comparison%20matrix%20where%20genes%20are%20ranked%20based%20on%20multiple%20statistical%20criteria%20(e.g.%2C%20t-test%2C%20entropy%2C%20ROC%2C%20Wilcoxon%2C%20and%20SNR).%0A%0A%20%20%20%20%20%20%20%20The%20matrix%20is%20required%20to%20be%20consistent%2C%20meaning%20that%20its%20elements%20must%20satisfy%20certain%20transitivity%20properties.%0A%20%20%20%20%20%20%20%20Eigenvectors%20are%20computed%20from%20this%20matrix%20to%20obtain%20ranking%20scores%20of%20genes.%20These%20eigenvectors%20correspond%20to%20the%20principal%20components%20that%20define%20the%20most%20discriminative%20genes.%0A%0A%20%20%20%20%20%20%20%20The%20largest%20eigenvalue%20(%F0%9D%9C%86%F0%9D%91%9A%F0%9D%91%8E%F0%9D%91%A5)%20is%20used%20to%20compute%20the%20Consistency%20Index%20(CI)%20and%20Consistency%20Ratio%20(CR)%20to%20ensure%20that%20the%20ranking%20process%20is%20mathematically%20sound.%0A%20%20%20%20%20%20%20%20Eigenvalues%20and%20Eigenvectors%20in%20HMMs%3A%0A%0A%20%20%20%20%20%20%20%20HMMs%20use%20transition%20probability%20matrices%20to%20model%20state%20changes%20in%20gene%20expression%20related%20to%20cancer%20progression.%0A%20%20%20%20%20%20%20%20The%20transition%20probability%20matrix%20(A)%20is%20a%20stochastic%20matrix%20that%20describes%20the%20likelihood%20of%20transitioning%20from%20one%20state%20to%20another.%0A%0A%20%20%20%20%20%20%20%20The%20stationary%20distribution%20of%20states%20(long-term%20probabilities%20of%20each%20state)%20is%20found%20by%20computing%20the%20dominant%20eigenvector%20(associated%20with%20eigenvalue%201)%20of%20this%20matrix.%0A%0A%20%20%20%20%20%20%20%20Spectral%20analysis%20(using%20eigenvalues)%20helps%20determine%20the%20stability%20and%20convergence%20properties%20of%20the%20HMM.%0A%20%20%20%20%20%20%20%20Why%20This%20Matters%20for%20Cancer%20Classification%0A%0A%20%20%20%20%20%20%20%20Gene%20Selection%20(AHP%20with%20Eigenvectors)%20ensures%20that%20the%20most%20informative%20genes%20are%20chosen%20based%20on%20multiple%20criteria%2C%20improving%20classification%20accuracy.%0A%0A%20%20%20%20%20%20%20%20HMMs%20with%20Eigenvalues%20provide%20a%20probabilistic%20framework%20to%20model%20cancer%20progression%20and%20classify%20gene%20expression%20data%20efficiently.%0A%0A%20%20%20%20%20%20%20%20Eigenvectors%20define%20important%20features%2C%20helping%20reduce%20computational%20complexity%20and%20improving%20stability.%0A%20%20%20%20%20%20%20%20%22%22%22%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(%0A%20%20%20%20%20%20%20%20r%22%22%22%0A%20%20%20%20%20%20%20%20%23%23%23%20%3Cspan%20style%3D%22color%3A%20brown%22%3EPairwise%20Comparison%20Matrix%20and%20Eigenvalues%20in%20Modified%20AHP%3C%2Fspan%3E%0A%0A%20%20%20%20%20%20%20%20The%20article%20describes%20the%20calculation%20of%20the%20**pairwise%20comparison%20matrix**%20and%20the%20**eigenvalues%20and%20eigenvectors**%20in%20the%20context%20of%20the%20**modified%20Analytic%20Hierarchy%20Process%20(AHP)**%20used%20for%20gene%20selection.%0A%0A%20%20%20%20%20%20%20%20%23%23%20**1.%20Construction%20of%20the%20Pairwise%20Comparison%20Matrix**%0A%20%20%20%20%20%20%20%20The%20pairwise%20comparison%20matrix%20%24X%20%3D%20(x_%7Bij%7D)%24%20is%20an%20%24n%20%5Ctimes%20n%24%20matrix%2C%20where%20each%20element%20%24x_%7Bij%7D%24%20represents%20the%20relative%20importance%20of%20gene%20%24i%24%20compared%20to%20gene%20%24j%24.%20The%20matrix%20satisfies%3A%0A%0A%20%20%20%20%20%20%20%20%24%24%0A%20%20%20%20%20%20%20%20x_%7Bij%7D%20%3D%20%5Cfrac%7B1%7D%7Bx_%7Bji%7D%7D%2C%20%5Cquad%20%5Cforall%20i%20%5Cneq%20j%0A%20%20%20%20%20%20%20%20%24%24%0A%0A%20%20%20%20%20%20%20%20%24%24%0A%20%20%20%20%20%20%20%20x_%7Bii%7D%20%3D%201%2C%20%5Cquad%20%5Cforall%20i%0A%20%20%20%20%20%20%20%20%24%24%0A%0A%20%20%20%20%20%20%20%20The%20elements%20of%20the%20matrix%20are%20computed%20based%20on%20**quantitative%20criteria**%2C%20which%20include%3A%0A%20%20%20%20%20%20%20%20-%20**t-test**%0A%20%20%20%20%20%20%20%20-%20**Entropy**%0A%20%20%20%20%20%20%20%20-%20**Receiver%20Operating%20Characteristic%20(ROC)%20curve**%0A%20%20%20%20%20%20%20%20-%20**Wilcoxon%20test**%0A%20%20%20%20%20%20%20%20-%20**Signal-to-Noise%20Ratio%20(SNR)**%0A%0A%20%20%20%20%20%20%20%20The%20absolute%20difference%20between%20the%20statistical%20values%20of%20two%20genes%20%24i%24%20and%20%24j%24%20is%20used%20to%20compute%20the%20pairwise%20importance%20score%3A%0A%0A%20%20%20%20%20%20%20%20%24%24%0A%20%20%20%20%20%20%20%20d_%7Bij%7D%20%3D%20%7Cc_i%20-%20c_j%7C%0A%20%20%20%20%20%20%20%20%24%24%0A%0A%20%20%20%20%20%20%20%20where%20%24c_i%24%20and%20%24c_j%24%20are%20the%20scores%20of%20genes%20%24i%24%20and%20%24j%24%20under%20the%20given%20criterion.%20The%20final%20matrix%20values%20are%20scaled%20within%20the%20range%20**%5B1%2C10%5D**%20using%3A%0A%0A%20%20%20%20%20%20%20%20%24%24%0A%20%20%20%20%20%20%20%20c%20%3D%20%5Cfrac%7Bd_%7Bij%7D%20-%209%7D%7Bc_%7B%5Cmax%7D%7D%20%2B%201%0A%20%20%20%20%20%20%20%20%24%24%0A%0A%20%20%20%20%20%20%20%20%24%24%0A%20%20%20%20%20%20%20%20x_%7Bij%7D%20%3D%0A%20%20%20%20%20%20%20%20%5Cbegin%7Bcases%7D%20%0A%20%20%20%20%20%20%20%20c%2C%20%26%20%5Ctext%7Bif%20%7D%20c_i%20%5Cgeq%20c_j%20%5C%5C%0A%20%20%20%20%20%20%20%20%5Cfrac%7B1%7D%7Bc%7D%2C%20%26%20%5Ctext%7Botherwise%7D%0A%20%20%20%20%20%20%20%20%5Cend%7Bcases%7D%0A%20%20%20%20%20%20%20%20%24%24%0A%0A%20%20%20%20%20%20%20%20where%20%24c_%7B%5Cmax%7D%24%20is%20the%20maximum%20distance%20between%20genes.%0A%0A%20%20%20%20%20%20%20%20%23%23%20**2.%20Eigenvector%20Calculation%20(Ranking%20Genes)**%0A%20%20%20%20%20%20%20%20Once%20the%20pairwise%20comparison%20matrix%20is%20constructed%2C%20**eigenvectors**%20are%20used%20to%20determine%20the%20ranking%20of%20genes.%20The%20eigenvector%20%24%5Clambda%24%20is%20computed%20using%3A%0A%0A%20%20%20%20%20%20%20%20%24%24%0A%20%20%20%20%20%20%20%20S_j%20%3D%20%5Csum_%7Bi%3D1%7D%5E%7Bn%7D%20x_%7Bij%7D%0A%20%20%20%20%20%20%20%20%24%24%0A%0A%20%20%20%20%20%20%20%20%24%24%0A%20%20%20%20%20%20%20%20%5Clambda_i%20%3D%20%5Cfrac%7B1%7D%7Bn%7D%20%5Csum_%7Bj%3D1%7D%5E%7Bn%7D%20%5Cfrac%7Bx_%7Bij%7D%7D%7BS_j%7D%0A%20%20%20%20%20%20%20%20%24%24%0A%0A%20%20%20%20%20%20%20%20This%20**normalized%20eigenvector**%20represents%20the%20ranking%20of%20genes.%0A%0A%20%20%20%20%20%20%20%20%23%23%20**3.%20Eigenvalue%20Calculation%20and%20Consistency%20Check**%0A%20%20%20%20%20%20%20%20The%20largest%20eigenvalue%20%24%5Clambda_%7B%5Cmax%7D%24%20is%20estimated%20as%3A%0A%0A%20%20%20%20%20%20%20%20%24%24%0A%20%20%20%20%20%20%20%20%5Clambda_%7B%5Cmax%7D%20%3D%20%5Cfrac%7B1%7D%7B%5Clambda_i%7D%20%5Csum_%7Bj%3D1%7D%5E%7Bn%7D%20x_%7Bij%7D%20%5Clambda_j%0A%20%20%20%20%20%20%20%20%24%24%0A%0A%20%20%20%20%20%20%20%20The%20**Consistency%20Index%20(CI)**%20is%20given%20by%3A%0A%0A%20%20%20%20%20%20%20%20%24%24%0A%20%20%20%20%20%20%20%20CI%20%3D%20%5Cfrac%7B%5Clambda_%7B%5Cmax%7D%20-%20n%7D%7Bn-1%7D%0A%20%20%20%20%20%20%20%20%24%24%0A%0A%20%20%20%20%20%20%20%20The%20**Consistency%20Ratio%20(CR)**%20is%20then%20computed%20using%20a%20**Random%20Index%20(RI)**%3A%0A%0A%20%20%20%20%20%20%20%20%24%24%0A%20%20%20%20%20%20%20%20CR%20%3D%20%5Cfrac%7BCI%7D%7BRI%7D%0A%20%20%20%20%20%20%20%20%24%24%0A%0A%20%20%20%20%20%20%20%20A%20**CR%20value%20%E2%89%A4%200.1**%20indicates%20an%20acceptable%20consistency%20level.%0A%0A%20%20%20%20%20%20%20%20%23%23%20**Summary**%0A%20%20%20%20%20%20%20%20-%20The%20pairwise%20comparison%20matrix%20is%20built%20using%20**quantitative%20ranking**%20instead%20of%20expert%20judgment.%0A%20%20%20%20%20%20%20%20-%20The%20eigenvector%20of%20the%20matrix%20determines%20the%20relative%20ranking%20of%20genes.%0A%20%20%20%20%20%20%20%20-%20The%20eigenvalue%20and%20consistency%20ratio%20ensure%20that%20the%20matrix%20is%20valid%20for%20decision-making.%0A%0A%20%20%20%20%20%20%20%20This%20method%20ensures%20an%20**objective**%20and%20**stable**%20way%20to%20rank%20genes%2C%20which%20improves%20classification%20accuracy%20in%20cancer%20detection%20using%20**Hidden%20Markov%20Models%20(HMMs)**.%0A%20%20%20%20%20%20%20%20%22%22%22%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.image(%0A%20%20%20%20%20%20%20%20%22AHPexplnation.png%22%2C%0A%20%20%20%20%20%20%20%20caption%3D%22The%20hierarchy%20of%20factors%20for%20gene%20selection%20by%20AHP.%22%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(pd)%3A%0A%20%20%20%20ahp_df%20%3D%20pd.read_csv('.%2FAHPresults%2Ffinal_Mod_ahp_scores.csv')%0A%20%20%20%20return%20(ahp_df%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(ahp_df%2C%20mo)%3A%0A%20%20%20%20import%20altair%20as%20alt%0A%0A%0A%20%20%20%20%23%20Sort%20and%20take%20top%20500%20genes%0A%20%20%20%20ahp_top%20%3D%20ahp_df.sort_values(by%3D%22Scores%22%2C%20ascending%3DFalse).iloc%5B%3A500%2C%20%3A%5D%0A%0A%20%20%20%20%23%20Ensure%20%22Gene%22%20column%20is%20retained%20and%20treated%20as%20string%0A%20%20%20%20ahp_top_scaled%20%3D%20ahp_top.copy()%0A%20%20%20%20ahp_top_scaled.iloc%5B%3A%2C%20-1%3A%5D%20*%3D%201e6%20%20%23%20Apply%20scaling%0A%20%20%20%20ahp_top_scaled%5B%22Gene%22%5D%20%3D%20ahp_top_scaled%5B%22Gene%22%5D.astype(str)%0A%20%20%20%20ahp_top_scaled%5B%22Scores%22%5D%20%3D%20ahp_top_scaled%5B%22Scores%22%5D.astype(float)%0A%20%20%20%20%23%20Selection%20for%20interactive%20brushing%0A%20%20%20%20brush%20%3D%20alt.selection_interval(encodings%3D%5B%22x%22%2C%20%22y%22%5D)%0A%20%20%20%20%23%20Scatter%20Plot%20(Interactive)%0A%20%20%20%20chart%20%3D%20mo.ui.altair_chart(%0A%20%20%20%20%20%20%20%20alt.Chart(ahp_top_scaled)%0A%20%20%20%20%20%20%20%20.mark_circle()%0A%20%20%20%20%20%20%20%20.encode(%0A%20%20%20%20%20%20%20%20%20%20%20%20x%3D%22Scores%3AQ%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20y%3D%22t_test%3AQ%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22entropy%3AQ%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20size%3D%22Wilcoxon%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20tooltip%3D%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Gene%3AN%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Scores%3AQ%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22t_test%3AQ%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22entropy%3AQ%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22roc_auc%3AQ%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Wilcoxon%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Wilcoxon_p%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22snr%3AQ%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%5D%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20.add_params(brush)%0A%20%20%20%20)%0A%20%20%20%20return%20ahp_top%2C%20ahp_top_scaled%2C%20alt%2C%20brush%2C%20chart%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(chart%2C%20mo)%3A%0A%20%20%20%20%23%20Display%20chart%20and%20dynamically%20updating%20table%0A%20%20%20%20mo.vstack(%5Bchart%2C%20mo.ui.table(chart.value)%5D)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(ahp_df%2C%20mo)%3A%0A%20%20%20%20mo.ui.data_explorer(ahp_df)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(%22%22%22Our%20ahp%20analysis%20shows%20that%20these%20are%20top%20500%20ranked%20genes%20associated%20with%20breast%20cancer%20and%20their%20function%20in%20the%20body.%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo%2C%20pd)%3A%0A%20%20%20%20desc_df%20%3D%20pd.read_csv(%22.%2Fdata%2Ftop500_desc.csv%22)%0A%20%20%20%20mo.ui.tabs(%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Visual_Analysis%22%3A%20mo.hstack(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20mo.md(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22%22%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%23%23%20%3Cspan%20style'%22color%3A%20green%22%3E%20ROC%20AUC%20vs%20AHP%20Scores%20%3C%2Fspan%3E%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20**U-shaped%20curve%3A**%20AHP%20scores%20are%20higher%20for%20genes%20with%20ROC%20AUC%20close%20to%200%20or%201%2C%20and%20lower%20near%200.5.%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20**Biological%20meaning%3A**%20Genes%20that%20strongly%20distinguish%20cancer%20subtypes%20(either%20positively%20or%20negatively)%20are%20prioritized.%20This%20includes%20both%20upregulated%20and%20downregulated%20biomarkers%2C%20suggesting%20AHP%20is%20sensitive%20to%20directional%20changes%20in%20gene%20activity%20relevant%20to%20breast%20cancer.%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%23%23%20%3Cspan%20style'%22color%3A%20green%22%3E%20SNR%20(Signal-to-Noise%20Ratio)%20vs%20AHP%20Scores%20%3C%2Fspan%3E%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20**Clear%20positive%20trend%3A**%20As%20SNR%20increases%2C%20so%20do%20AHP%20scores.%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20**Biological%20meaning%3A**%20Genes%20with%20strong%20expression%20differences%20and%20low%20intra-class%20variability%20are%20ranked%20higher.%20These%20are%20likely%20stable%20and%20robust%20breast%20cancer%20biomarkers%2C%20capable%20of%20separating%20cancerous%20vs.%20non-cancerous%20or%20different%20subtypes%20(e.g.%2C%20HER2%2B%20vs.%20triple-negative%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%23%23%20%3Cspan%20style'%22color%3A%20green%22%3E%20t-test%20Statistic%20vs%20AHP%20Scores%20%3C%2Fspan%3E%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20**Strong%20linear%20correlation%3A**%20Higher%20t-values%20lead%20to%20higher%20AHP%20scores.%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20**Biological%20meaning%3A**%20AHP%20emphasizes%20genes%20that%20show%20statistically%20significant%20differential%20expression%20between%20groups.%20This%20supports%20the%20discovery%20of%20potential%20diagnostic%20or%20prognostic%20genes%20involved%20in%20tumor%20behavior%2C%20estrogen%20receptor%20signaling%2C%20or%20aggressiveness.%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%23%23%20%3Cspan%20style'%22color%3A%20green%22%3E%20%20Wilcoxon%20Statistic%20and%20Wilcoxon%20p%20values%20vs%20AHP%20Scores%20%3C%2Fspan%3E%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20**Positive%20correlation**%2C%20especially%20at%20higher%20Wilcoxon%20values.%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20**Biological%20meaning%3A**%20Even%20in%20non-parametric%20comparisons%2C%20AHP%20is%20sensitive%20to%20expression%20shifts.%20This%20indicates%20robustness%20to%20outliers%20and%20validates%20genes%20that%20may%20not%20follow%20normal%20distribution%2C%20which%20is%20common%20in%20real%20patient%20gene%20expression%20profiles.%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20**Low%20p-values%20(~0)%20align%20with%20high%20AHP%20scores**%2C%20but%20score%20distribution%20shows%20banding%20patterns.%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20**Biological%20meaning%3A**%20Genes%20with%20statistically%20significant%20differences%20in%20expression%20across%20conditions%20(e.g.%2C%20cancer%20subtypes%20or%20stages)%20are%20appropriately%20prioritized.%20The%20banding%20may%20reflect%20discrete%20thresholds%20or%20tied%20rankings%20from%20AHP%2C%20often%20seen%20when%20many%20genes%20have%20similar%20significance%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22%22%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20mo.vstack(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20mo.image(%22rocVahp.png%22)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20mo.image(%22snrVahp.png%22)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20mo.image(%22t_testVahp.png%22)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20mo.image(%22wilcoxonVahp.png%22)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22top%20500%20genes%20and%20thei%20info%22%3A%20mo.ui.table(desc_df)%2C%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20)%0A%20%20%20%20return%20(desc_df%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(%0A%20%20%20%20%20%20%20%20r%22%22%22%0A%20%20%20%20%20%20%20%20%23%23%23%20%3Cspan%20style%3D'color%3A%20brown'%3EPrognosis%20Analysis%3C%2Fspan%3E%0A%0A%20%20%20%20%20%20%20%20The%20prognosis%20for%20cancer%20refers%20to%20the%20expected%20outcome%20or%20course%20of%20the%20disease%2C%20including%20the%20likelihood%20of%20survival%20and%20recurrence.%20It's%20a%20doctor's%20best%20estimate%20based%20on%20various%20factors%20related%20to%20the%20cancer%20itself%20and%20the%20patient's%20overall%20health.%20Prognosis%20is%20influenced%20by%20factors%20like%20the%20type%20and%20stage%20of%20cancer%2C%20the%20patient's%20age%20and%20health%2C%20and%20how%20the%20cancer%20responds%20to%20treatment.%20%0A%0A%20%20%20%20%20%20%20%20We%20were%20initially%20planning%20to%20use%20Morkov%20model%20or%20Boosting%20algorithm%20to%20calculate%20transition%20probability%20of%20cancer%20stage%20to%20another.%20However%20since%20we%20dont%20have%20data%20that%20record%20stage%20progression%20we%20cant%20predict%20that.%20However%20we%20can%20futher%20analyze%20the%20probability%20of%20a%20patient%20get%20diagnosed%20with%20each%20stage.%20Our%20data%20can%20help%20us%20to%20also%20further%20study%20cancer%20sage%20with%20respect%20to%20parient's%20demographic%20and%20also%20study%20melignant%20samples%20by%20their%20size%2C%20lumpth%20nodes%20and%20their%20spread%20on%20to%20the%20other%20organisms.%20%0A%0A%0A%20%20%20%20%20%20%20%20**%3Cspan%20style%3D'color%3A%20brown'%3EInitial%20Probability%20Calculation%3C%2Fspan%3E**%0A%0A%20%20%20%20%20%20%20%20The%20initial%20probability%20of%20a%20stage%20%5C(%20S_i%20%5C)%20is%20calculated%20by%20counting%20the%20occurrences%20of%20each%20stage%20in%20the%20dataset%20and%20dividing%20by%20the%20total%20number%20of%20samples.%20However%2C%20if%20the%20dataset%20is%20unbalanced%2C%20the%20probability%20calculation%20will%20be%20biased.%20To%20mitigate%20this%20bias%2C%20we%20apply%20a%20weight%20to%20each%20stage%20to%20balance%20the%20contributions%3A%0A%0A%20%20%20%20%20%20%20%20%5C%5B%0A%20%20%20%20%20%20%20%20P(S_i)%20%3D%20%5Cfrac%7Bw_i%20%5Ctimes%20N_i%7D%7B%5Csum_%7Bj%7D%20w_j%20%5Ctimes%20N_j%7D%0A%20%20%20%20%20%20%20%20%5C%5D%0A%0A%20%20%20%20%20%20%20%20Where%3A%0A%20%20%20%20%20%20%20%20-%20%5C(%20N_i%20%5C)%20is%20the%20number%20of%20samples%20in%20stage%20%5C(%20S_i%20%5C).%0A%20%20%20%20%20%20%20%20-%20%5C(%20w_i%20%3D%20%5Cfrac%7BN_%7B%5Ctext%7Bmin%7D%7D%7D%7BN_i%7D%20%5C)%20is%20the%20weight%20assigned%20to%20stage%20%5C(%20S_i%20%5C)%2C%20where%20%5C(%20N_%7B%5Ctext%7Bmin%7D%7D%20%5C)%20is%20the%20count%20of%20the%20stage%20with%20the%20fewest%20samples.%0A%0A%20%20%20%20%20%20%20%20%23%23%23%20%3Cspan%20style%3D'color%3A%20brown'%3EUtilizing%20Catboost%3C%2Fspan%3E%0A%0A%20%20%20%20%20%20%20%20CatBoost%20is%20a%20powerful%20gradient%20boosting%20algorithm%2C%20and%20can%20learn%20the%20underlying%20relationships%20between%20clinical%20and%20demographic%20features%20and%20cancer%20stage%20outcomes%20directly%20from%20the%20data.%20By%20training%20on%20features%20such%20as%20age%2C%20tumor%20size%2C%20lymph%20node%20involvement%2C%20metastasis%2C%20and%20patient%20ethnicity%2C%20CatBoost%20can%20model%20the%20probability%20of%20a%20patient%20being%20diagnosed%20at%20each%20cancer%20stage.%20It%20internally%20handles%20class%20imbalance%20through%20loss%20functions%20and%20built-in%20support%20for%20weighted%20datasets%2C%20allowing%20it%20to%20estimate%20class%20probabilities%20more%20accurately%20even%20when%20stage%20distributions%20are%20skewed.%20Thus%2C%20while%20we%20cannot%20trace%20how%20a%20patient%20moves%20from%20one%20stage%20to%20another%2C%20CatBoost%20enables%20us%20to%20assess%20the%20likelihood%20of%20a%20patient%20presenting%20with%20a%20specific%20stage%2C%20based%20on%20their%20biological%20and%20demographic%20profile.%0A%0A%20%20%20%20%20%20%20%20CatBoost%20offers%20built-in%20support%20for%20handling%20imbalanced%20classes%20using%20the%20auto_class_weights%20parameter%2C%20which%20automatically%20calculates%20class%20weights%20to%20ensure%20that%20minority%20classes%20are%20not%20underrepresented%20during%20training.%20This%20is%20especially%20useful%20in%20cancer%20prognosis%20tasks%2C%20where%20certain%20stages%20may%20have%20far%20fewer%20samples.%20You%20can%20specify%20values%20like%20%22Balanced%22%20or%20%22SqrtBalanced%22%20to%20control%20how%20the%20class%20weights%20are%20computed%20based%20on%20either%20direct%20ratios%20or%20square-root-scaled%20ratios.%20These%20weights%20are%20then%20used%20internally%20to%20modify%20the%20loss%20function%2C%20allowing%20the%20model%20to%20learn%20equally%20well%20from%20all%20classes%20despite%20imbalance.%20For%20example%2C%20in%20the%20%22Balanced%22%20setting%2C%20the%20class%20weight%20%0A%0A%20%20%20%20%20%20%20%20**Balanced%3A**%0A%0A%20%20%20%20%20%20%20%20%5C%5B%0A%20%20%20%20%20%20%20%20CW_k%20%3D%20%5Cfrac%7B%5Cmax%5Climits_%7Bc%3D1%7D%5E%7BK%7D%20%5Cleft(%20%5Csum_%7Bt_i%3Dc%7D%20w_i%20%5Cright)%7D%7B%5Csum_%7Bt_i%3Dk%7D%20w_i%7D%0A%20%20%20%20%20%20%20%20%5C%5D%0A%0A%20%20%20%20%20%20%20%20**SqrtBalanced%3A**%0A%0A%20%20%20%20%20%20%20%20%5C%5B%0A%20%20%20%20%20%20%20%20CW_k%20%3D%20%5Csqrt%7B%20%5Cfrac%7B%5Cmax%5Climits_%7Bc%3D1%7D%5E%7BK%7D%20%5Cleft(%20%5Csum_%7Bt_i%3Dc%7D%20w_i%20%5Cright)%7D%7B%5Csum_%7Bt_i%3Dk%7D%20w_i%7D%20%7D%0A%20%20%20%20%20%20%20%20%5C%5D%0A%20%20%20%20%20%20%20%20%22%22%22%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(pd)%3A%0A%20%20%20%20%22%22%22%0A%20%20%20%20loading%20calculated%20probabilities%20from%20our%20csvs%0A%20%20%20%20%22%22%22%0A%20%20%20%20initial_p_df%20%3D%20pd.read_csv('..%2FModels%2FHMM%2FprobabilitiesResults%2Fweighted_initial_p.csv')%0A%20%20%20%20emmition_p_df%20%3D%20pd.read_csv('..%2FModels%2FHMM%2FprobabilitiesResults%2Fcombined_em_p.csv')%0A%20%20%20%20transition_p_df%20%3D%20pd.read_csv('..%2FModels%2FHMM%2FprobabilitiesResults%2Fweighted_ts_p.csv')%0A%20%20%20%20return%20emmition_p_df%2C%20initial_p_df%2C%20transition_p_df%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo%2C%20pd%2C%20px)%3A%0A%20%20%20%20%23%20Load%20data%0A%20%20%20%20model_data%20%3D%20pd.read_csv('.%2FAHPresults%2Ffina_Stage_unaugmented.csv')%0A%20%20%20%20stage_p_df%20%3D%20pd.read_csv('..%2FModels%2Fgbst%2Fresult%2Fstage_result.csv'%2C%20index_col%3D0)%0A%20%20%20%20model_matrix%20%3D%20pd.read_csv('..%2FModels%2Fgbst%2Fresult%2Fclassification_mtrx.csv'%2C%20index_col%3D0)%0A%20%20%20%20gdp_matrix%20%3D%20pd.read_csv('..%2FModels%2Fgbst%2Fresult%2Fgdb_p_result.csv')%0A%20%20%20%20manually_calc_prop%20%3D%20pd.read_csv('..%2FModels%2FHMM%2FprobabilitiesResults%2Fweighted_initial_p.csv')%0A%0A%20%20%20%20%23%20Format%20'count'%20column%20to%202%20decimal%20places%20for%20display%0A%20%20%20%20manually_calc_prop%5B'count'%5D%20%3D%20manually_calc_prop%5B'count'%5D.round(2)%0A%20%20%20%20manually_calc_prop.rename(columns%3D%7B'count'%3A%20'calculate_p'%7D%2C%20inplace%3DTrue)%0A%0A%0A%20%20%20%20%23%20Merge%20stage%20probabilities%20with%20manually%20calculated%20probabilities%0A%20%20%20%20merged_df%20%3D%20stage_p_df.merge(manually_calc_prop%2C%20left_on%3Dstage_p_df.index%2C%20right_on%3Dmanually_calc_prop%5B'Stage'%5D)%0A%0A%20%20%20%20%23%20Drop%20'Stage'%20column%20if%20no%20longer%20needed%0A%20%20%20%20merged_df.drop(columns%3D'Stage'%2C%20inplace%3DTrue)%0A%0A%20%20%20%20%23%20Plot%20stage%20probabilities%0A%20%20%20%20stage_fig%20%3D%20px.bar(%0A%20%20%20%20%20%20%20%20merged_df%2C%0A%20%20%20%20%20%20%20%20x%3Dmerged_df.index%2C%0A%20%20%20%20%20%20%20%20y%3D%5B'Estimated%20Probability'%2C%20'calculate_p'%5D%0A%20%20%20%20)%0A%0A%20%20%20%20%23%20Aggregate%20GDP%20matrix%20for%20True%20Stage%0A%20%20%20%20columns_to_sum%20%3D%20gdp_matrix.columns.drop('True%20Stage')%0A%20%20%20%20gdp_agg%20%3D%20gdp_matrix.groupby('True%20Stage')%5Bcolumns_to_sum%5D.mean().reset_index()%0A%0A%20%20%20%20%23%20Create%20image%20heatmap%20of%20GDP%20aggregated%20results%0A%20%20%20%20gdg_fig%20%3D%20px.imshow(gdp_agg.iloc%5B%3A%2C%201%3A%5D)%0A%0A%20%20%20%20%23%20Display%20in%20Marimo%20tabs%0A%20%20%20%20mo.ui.tabs(%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20'Stage%20Diagnosis%20Probability'%3A%20mo.vstack(%5Bmo.ui.plotly(stage_fig)%2C%20mo.ui.table(model_data)%5D)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20'CatBoost%20Performance'%3A%20mo.hstack(%5Bmo.ui.plotly(gdg_fig)%2C%20mo.ui.table(model_matrix)%5D)%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20)%0A%20%20%20%20return%20(%0A%20%20%20%20%20%20%20%20columns_to_sum%2C%0A%20%20%20%20%20%20%20%20gdg_fig%2C%0A%20%20%20%20%20%20%20%20gdp_agg%2C%0A%20%20%20%20%20%20%20%20gdp_matrix%2C%0A%20%20%20%20%20%20%20%20manually_calc_prop%2C%0A%20%20%20%20%20%20%20%20merged_df%2C%0A%20%20%20%20%20%20%20%20model_data%2C%0A%20%20%20%20%20%20%20%20model_matrix%2C%0A%20%20%20%20%20%20%20%20stage_fig%2C%0A%20%20%20%20%20%20%20%20stage_p_df%2C%0A%20%20%20%20)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(%0A%20%20%20%20%20%20%20%20r%22%22%22%0A%20%20%20%20%20%20%20%20%23%23%23%20%3Cspan%20style%3D%22color%3A%20brown%22%3EKey%20Observations%3A%3C%2Fspan%3E%0A%0A%20%20%20%20%20%20%20%20The%20comparison%20between%20CatBoost-estimated%20stage%20probabilities%20and%20the%20manually%20weighted%20probabilities%20highlights%20a%20consistent%20pattern%3A%20early-stage%20diagnoses%20(e.g.%2C%20Stage%20IIA%2C%20IIB)%20are%20predicted%20with%20higher%20probability%2C%20while%20late-stage%20diagnoses%20(e.g.%2C%20Stage%20IV)%20receive%20lower%20predicted%20probabilities.%0A%0A%20%20%20%20%20%20%20%20This%20makes%20sense%20within%20the%20clinical%20context%20of%20breast%20cancer%2C%20where%20advanced%20stages%20are%20rare%20at%20the%20point%20of%20initial%20diagnosis.%20According%20to%20the%20American%20Cancer%20Society%2C%20the%20majority%20of%20invasive%20breast%20cancers%20are%20diagnosed%20in%20early%20stages%2C%20and%20Stage%20IV%20cases%20account%20for%20a%20small%20minority%20of%20breast%20cancer%20presentations.%20This%20supports%20the%20biological%20plausibility%20of%20the%20lower%20predicted%20probabilities%20for%20late-stage%20cancers%2C%20rather%20than%20indicating%20bias%20or%20model%20weakness.%0A%0A%20%20%20%20%20%20%20%20%23%23%23%20%3Cspan%20style%3D%22color%3A%20brown%22%3EConclusion%20(In%20the%20Context%20of%20Prognosis%20and%20Biomarker%20Analysis)%3C%2Fspan%3E%0A%0A%20%20%20%20%20%20%20%20These%20findings%20reinforce%20the%20reliability%20of%20gene%20expression%20and%20clinical%20features%20in%20distinguishing%20between%20breast%20cancer%20stages%2C%20even%20in%20the%20absence%20of%20longitudinal%20data.%20While%20we%20cannot%20track%20stage%20transitions%20over%20time%2C%20we%20can%20use%20machine%20learning%20to%20assess%20the%20likelihood%20of%20a%20patient%20being%20diagnosed%20at%20a%20specific%20stage%2C%20based%20on%20their%20molecular%20and%20demographic%20profile.%0A%0A%20%20%20%20%20%20%20%20In%20this%20study%2C%20stage%20probabilities%20learned%20from%20CatBoost%20serve%20as%20a%20proxy%20for%20prognosis%20analysis%2C%20especially%20when%20tied%20back%20to%20gene-level%20biomarker%20rankings%20derived%20from%20our%20AHP%20method.%20The%20model%E2%80%99s%20tendency%20to%20assign%20lower%20probabilities%20to%20later%20stages%20mirrors%20real-world%20clinical%20distribution%20and%20strengthens%20the%20case%20that%20our%20biomarker-based%20models%20are%20capturing%20true%20biological%20signals%20relevant%20to%20diagnosis%20and%20prognosis.%0A%0A%20%20%20%20%20%20%20%20Ultimately%2C%20this%20validates%20our%20approach%20of%20combining%20modified%20AHP%20for%20gene%20ranking%20with%20CatBoost%20classification%20for%20prognosis%20modeling%2C%20creating%20a%20biologically%20informed%20and%20statistically%20sound%20method%20for%20supporting%20early%20detection%20and%20precision%20diagnostics%20in%20breast%20cancer%20care.%0A%20%20%20%20%20%20%20%20%22%22%22%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(%0A%20%20%20%20%20%20%20%20r%22%22%22%0A%20%20%20%20%20%20%20%20%23%23%23%3Cspan%20style%3D%22color%3Abrown%22%3EMedical%20Terminalogies%20for%20Cancer%20Staging%3C%2Fspan%3E%0A%0A%20%20%20%20%20%20%20%20**Cancer%20Staging%3A**%0A%0A%20%20%20%20%20%20%20%20Stage%20refers%20to%20the%20extent%20of%20your%20cancer%2C%20such%20as%20how%20large%20the%20tumor%20is%20and%20if%20it%20has%20spread.%20%0A%0A%20%20%20%20%20%20%20%20**Systems%20That%20Describe%20Stage%3A**%0A%0A%20%20%20%20%20%20%20%20There%20are%20many%20staging%20systems.%20Some%2C%20such%20as%20the%20TNM%20staging%20system%2C%20are%20used%20for%20many%20types%20of%20cancer.%20Others%20are%20specific%20to%20a%20particular%20type%20of%20cancer.%20Most%20staging%20systems%20include%20information%20about%20where%20the%20tumor%20is%20located%20in%20the%20body%0A%20%20%20%20%20%20%20%20the%20size%20of%20the%20tumor%20whether%20the%20cancer%20has%20spread%20to%20nearby%20lymph%20nodes%0A%20%20%20%20%20%20%20%20whether%20the%20cancer%20has%20spread%20to%20a%20different%20part%20of%20the%20body%0A%0A%20%20%20%20%20%20%20%20**The%20TNM%20Staging%20System**%0A%0A%20%20%20%20%20%20%20%20The%20TNM%20system%20is%20the%20most%20widely%20used%20cancer%20staging%20system.%20Most%20hospitals%20and%20medical%20centers%20use%20the%20TNM%20system%20as%20their%20main%20method%20for%20cancer%20reporting.%20You%20are%20likely%20to%20see%20your%20cancer%20described%20by%20this%20staging%20system%20in%20your%20pathology%20report%20unless%20there%20is%20a%20different%20staging%20system%20for%20your%20type%20of%20cancer.%20Examples%20of%20cancers%20with%20different%20staging%20systems%20include%20brain%20and%20spinal%20cord%20tumors%20and%20blood%20cancers.%20%0A%0A%20%20%20%20%20%20%20%20In%20the%20TNM%20system%3A%0A%0A%20%20%20%20%20%20%20%20*%20The%20T%20refers%20to%20the%20size%20and%20extent%20of%20the%20main%20tumor.%20The%20main%20tumor%20is%20usually%20called%20the%20primary%20tumor.%0A%20%20%20%20%20%20%20%20*%20The%20N%20refers%20to%20the%20number%20of%20nearby%20lymph%20nodes%20that%20have%20cancer.%0A%20%20%20%20%20%20%20%20*%20The%20M%20refers%20to%20whether%20the%20cancer%20has%20metastasized.%20This%20means%20that%20the%20cancer%20has%20spread%20from%20the%20primary%20tumor%20to%20other%20parts%20of%20the%20body.%0A%20%20%20%20%20%20%20%20*%20When%20your%20cancer%20is%20described%20by%20the%20TNM%20system%2C%20there%20will%20be%20numbers%20after%20each%20letter%20that%20give%20more%20details%20about%20the%20cancer%E2%80%94for%20example%2C%20T1N0MX%20or%20T3N1M0.%20The%20following%20explains%20what%20the%20letters%20and%20numbers%20mean.%0A%0A%20%20%20%20%20%20%20%20Primary%20tumor%20(T)%3A%0A%0A%20%20%20%20%20%20%20%20*%20TX%3A%20Main%20tumor%20cannot%20be%20measured.%0A%20%20%20%20%20%20%20%20*%20T0%3A%20Main%20tumor%20cannot%20be%20found.%0A%20%20%20%20%20%20%20%20*%20T1%2C%20T2%2C%20T3%2C%20T4%3A%20Refers%20to%20the%20size%20and%2For%20extent%20of%20the%20main%20tumor.%20The%20higher%20the%20number%20after%20the%20T%2C%20the%20larger%20the%20tumor%20or%20the%20more%20it%20has%20grown%20into%20nearby%20tissues.%20*%20*%20T's%20may%20be%20further%20divided%20to%20provide%20more%20detail%2C%20such%20as%20T3a%20and%20T3b.%0A%0A%20%20%20%20%20%20%20%20Regional%20lymph%20nodes%20(N)%3A%0A%0A%20%20%20%20%20%20%20%20*%20NX%3A%20Cancer%20in%20nearby%20lymph%20nodes%20cannot%20be%20measured.%0A%20%20%20%20%20%20%20%20*%20N0%3A%20There%20is%20no%20cancer%20in%20nearby%20lymph%20nodes.%0A%20%20%20%20%20%20%20%20*%20N1%2C%20N2%2C%20N3%3A%20Refers%20to%20the%20number%20and%20location%20of%20lymph%20nodes%20that%20contain%20cancer.%20The%20higher%20the%20number%20after%20the%20N%2C%20the%20more%20lymph%20nodes%20that%20contain%20cancer.%0A%0A%20%20%20%20%20%20%20%20Distant%20metastasis%20(M)%0A%0A%20%20%20%20%20%20%20%20*%20MX%3A%20Metastasis%20cannot%20be%20measured.%0A%20%20%20%20%20%20%20%20*%20M0%3A%20Cancer%20has%20not%20spread%20to%20other%20parts%20of%20the%20body.%0A%20%20%20%20%20%20%20%20*%20M1%3A%20Cancer%20has%20spread%20to%20other%20parts%20of%20the%20body.%0A%20%20%20%20%20%20%20%20%22%22%22%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.image('.%2FBRCA_StageGrouping.png')%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.hstack(%5B%0A%20%20%20%20%20%20%20%20mo.md(f%22%22%22%0A%20%20%20%20%20%20%20%20**%3Cspan%20style%3D%22color%3A%20brown%22%3EIntroduction%20to%20miRNA%20Clusters%20in%20Breast%20Cancer%20Analysis%3C%2Fspan%3E**%0A%0A%20%20%20%20MicroRNAs%20(miRNAs)%20are%20small%2C%20non-coding%20RNAs%20that%20regulate%20gene%20expression%20by%20binding%20to%20mRNAs%2C%20thereby%20influencing%20critical%20cellular%20processes%20such%20as%20cell%20growth%2C%20apoptosis%2C%20metastasis%2C%20and%20immune%20response.%20In%20breast%20cancer%2C%20dysregulated%20miRNA%20expression%20is%20closely%20associated%20with%20disease%20progression%2C%20including%20tumor%20size%2C%20lymph%20node%20involvement%2C%20distant%20metastasis%2C%20and%20treatment%20response.%0A%0A%20%20%20%20miRNA%20clusters%20refer%20to%20groups%20of%20miRNAs%20that%20are%20either%20transcribed%20together%20from%20a%20common%20genomic%20region%20or%20exhibit%20similar%20expression%20patterns%20across%20samples.%20Clustering%20analysis%20helps%20identify%20patterns%20associated%20with%20distinct%20clinical%20features%2C%20providing%20insights%20into%20their%20potential%20role%20as%20biomarkers%20for%20prognosis%20and%20treatment%20outcomes.%0A%0A%20%20%20%20The%20following%20visualizations%20illustrate%20the%20distribution%20of%20miRNA%20clusters%20across%20various%20tumor%20sizes%2C%20lymph%20node%20involvement%20stages%2C%20and%20distant%20metastasis%20status%2C%20highlighting%20their%20relevance%20in%20breast%20cancer%20prognosis.%0A%20%20%20%20%20%20%20%20%22%22%22)%2C%0A%20%20%20%20%20%20%20%20mo.image('https%3A%2F%2Fwww.mayoclinic.org%2F-%2Fmedia%2Fkcms%2Fgbs%2Fpatient-consumer%2Fimages%2F2013%2F08%2F26%2F09%2F58%2Fbr00022_im04258_br7_metastatic_breast_cancerthu_jpg.png'%2C%20width%3D%20500%2C%20height%3D400)%0A%20%20%20%20%5D)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo%2C%20model_data)%3A%0A%20%20%20%20%23%20Creating%20DataFrames%20from%20value_counts()%20instead%20of%20converting%20to%20dictionary%0A%20%20%20%20regional_lymph%20%3D%20model_data%5B%5B'Stage'%2C%20'ajcc_pathologic_n'%2C'paper_miRNA.Clusters'%2C'ethnicity'%2C'race'%2C%20'age_at_diagnosis'%2C%20'vital_status'%5D%5D.value_counts().reset_index(name%3D'value')%0A%20%20%20%20size%20%3D%20model_data%5B%5B'Stage'%2C%20'ajcc_pathologic_t'%2C'paper_miRNA.Clusters'%2C'ethnicity'%2C'race'%2C%20'age_at_diagnosis'%2C%20'vital_status'%5D%5D.value_counts().reset_index(name%3D'value')%0A%20%20%20%20metastasize%20%3D%20model_data%5B%5B'Stage'%2C%20'ajcc_pathologic_m'%2C'paper_miRNA.Clusters'%2C'ethnicity'%2C'race'%2C%20'age_at_diagnosis'%2C%20'vital_status'%5D%5D.value_counts().reset_index(name%3D'value')%0A%0A%20%20%20%20%23%20Displaying%20them%20in%20the%20UI%20as%20separate%20tabs%0A%20%20%20%20data_table%20%3D%20mo.ui.tabs(%7B%0A%20%20%20%20%20%20%20%20'Tumor%20Size'%3A%20mo.ui.table(size.sort_values(by%3D'Stage'))%2C%0A%20%20%20%20%20%20%20%20'Regional%20lymph%20nodes'%3A%20mo.ui.table(regional_lymph.sort_values(by%3D'Stage'))%2C%0A%20%20%20%20%20%20%20%20'Distant%20metastasis'%3A%20mo.ui.table(metastasize.sort_values(by%3D'Stage'))%0A%20%20%20%20%7D)%0A%20%20%20%20return%20data_table%2C%20metastasize%2C%20regional_lymph%2C%20size%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(%0A%20%20%20%20%20%20%20%20r%22%22%22%0A%20%20%20%20%20%20%20%20%23%23%23%20%3Cspan%20style%3D'color%3Abrown'%3ECox%20Proportional%20Hazards%20Model%20in%20Our%20Study%3C%2Fspan%3E%0A%0A%20%20%20%20%20%20%20%20For%20our%20breast%20cancer%20prognosis%20study%2C%20we%20use%20the%20Cox%20Proportional%20Hazards%20Model%20to%20understand%20how%20clinical%20and%20molecular%20factors%20influence%20a%20patient's%20risk%20of%20mortality%20over%20time.%20While%20our%20dataset%20lacks%20exact%20time-to-death%2C%20we%20approximate%20follow-up%20duration%20based%20on%20diagnosis%20year%20to%20estimate%20survival%20outcomes.%20By%20modeling%20variables%20like%20tumor%20characteristics%20(T%2FN%2FM)%2C%20age%20at%20diagnosis%2C%20ethnicity%2C%20race%2C%20and%20miRNA%20expression%20clusters%2C%20we%20identify%20which%20features%20are%20associated%20with%20higher%20or%20lower%20hazard%20(risk)%20of%20death.%20This%20helps%20us%20interpret%20the%20prognostic%20value%20of%20key%20biomarkers%20and%20demographic%20factors%20in%20breast%20cancer%20outcomes.%0A%20%20%20%20%20%20%20%20%22%22%22%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(model_data)%3A%0A%20%20%20%20alternate_table%20%3D%20model_data%5B%5B'Stage'%2C%20%20'year_of_diagnosis'%2C'ajcc_pathologic_t'%2C%20'ajcc_pathologic_n'%2C'ajcc_pathologic_m'%2C'paper_miRNA.Clusters'%2C'ethnicity'%2C'race'%2C%20'age_at_diagnosis'%2C%20'vital_status'%5D%5D%0A%20%20%20%20%23convert%20age%20from%20days%20to%20year%0A%20%20%20%20alternate_table%5B'age_at_diagnosis'%5D%3Dalternate_table%5B'age_at_diagnosis'%5D.apply(lambda%20age%3A%20float(age%2F365))%0A%20%20%20%20%22%22%22%0A%0A%20%20%20%200%E2%80%934%20years%20Infants%2FToddlers%0A%20%20%20%205%E2%80%9314%20years%20Childhood%0A%20%20%20%2015%E2%80%9319%20years%20Adolescents%0A%20%20%20%2020-29%20Young%20Adults%0A%20%20%20%2030-49%20Adults%0A%20%20%20%2050%E2%80%9364%20Middle-Aged%20Adults%0A%20%20%20%2065%20-%20%20Seniors%0A%0A%20%20%20%20%22%22%22%0A%20%20%20%20def%20age_group(age)%3A%0A%20%20%20%20%20%20%20%20if%20age%20%3C%3D%204%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20return%20'Infants%2FToddlers'%0A%20%20%20%20%20%20%20%20elif%204%20%3C%20age%20%3C%3D%2014%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20return%20'Childhood'%0A%20%20%20%20%20%20%20%20elif%2014%20%3C%20age%20%3C%3D%2019%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20return%20'Adolescents'%0A%20%20%20%20%20%20%20%20elif%2019%20%3C%20age%20%3C%3D%2029%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20return%20'Young%20Adults'%0A%20%20%20%20%20%20%20%20elif%2029%20%3C%20age%20%3C%3D%2049%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20return%20'Adults'%0A%20%20%20%20%20%20%20%20elif%2049%20%3C%20age%20%3C%3D%2064%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20return%20'Middle-Aged%20Adults'%0A%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20return%20'Seniors'%0A%20%20%20%20alternate_table%5B'age_at_diagnosis'%5D%20%3D%20alternate_table%5B'age_at_diagnosis'%5D.apply(age_group)%0A%20%20%20%20return%20age_group%2C%20alternate_table%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo%2C%20pd%2C%20px)%3A%0A%20%20%20%20%23import%20data%0A%20%20%20%20cox_hazerdus_p%20%3D%20pd.read_csv('..%2FModels%2FCoxPHFitter%2Fresult%2Fcox_comparison_metrics.csv')%0A%20%20%20%20cox_hazerdus_p.drop(columns%3D'cmp%20to'%2C%20inplace%3DTrue)%0A%20%20%20%20cox_summry%20%3D%20pd.read_csv('..%2FModels%2FCoxPHFitter%2Fresult%2Fcox_model_summary.csv'%2Cindex_col%3D0)%0A%20%20%20%20cox_summry%20%3D%20cox_summry.T%0A%20%20%20%20%23%20Replace%20any%20values%20%3E%2010%20with%20NaN%20(or%20clip%20at%2010%20if%20you%20prefer)%0A%20%20%20%20cox_summry_numeric%20%3D%20cox_summry.select_dtypes(include%3D'number')%0A%20%20%20%20cox_summry%5Bcox_summry_numeric.columns%5D%20%3D%20cox_summry_numeric.where(cox_summry_numeric%20%3C%3D%2010)%0A%20%20%20%20hazard_fig%20%3D%20px.bar(cox_hazerdus_p%2C%20x%3D'covariate'%2C%20y%3D'p'%2C%20color%3D'z')%0A%20%20%20%20%23%20cox_summry.set_index('covariate'%2Cinplace%3DTrue)%0A%20%20%20%20summery_fig%20%3D%20px.imshow(cox_summry)%0A%0A%20%20%20%20insight%20%3D%20mo.md(f%22%22%22%0A%20%20%20%20%23%23%23%20%3Cspan%20style%3D'color%3Abrown'%3EKey%20Findings%3C%2Fspan%3E%0A%0A%20%20%20%20**%3Cspan%20style%3D'color%3Abrown'%3EElevated%20Risk%20Among%20Asian%20Populations%3A%3C%2Fspan%3E**%0A%0A%20%20%20%20*%20The%20model%20indicates%20that%20individuals%20identified%20as%20Asian%20have%20a%20higher%20hazard%20ratio%20compared%20to%20the%20reference%20group%20(White%20individuals).%20%20%0A%20%20%20%20*%20This%20aligns%20with%20epidemiological%20data%20showing%20that%20cancer%20is%20the%20leading%20cause%20of%20death%20among%20Asian%20Americans%2C%20with%20higher%20incidences%20of%20liver%2C%20stomach%2C%20and%20nasopharyngeal%20cancers.%20%20%0A%20%20%20%20%20%20%5BSource%3A%20PMC%5D(https%3A%2F%2Fwww.ncbi.nlm.nih.gov%2Fpmc%2Farticles%2FPMC5283572%2F)%0A%0A%20%20%20%20**%3Cspan%20style%3D'color%3Abrown'%3EAge-Related%20Risks%3A%3C%2Fspan%3E**%0A%0A%20%20%20%20*%20Seniors%20exhibit%20a%20significantly%20higher%20hazard%20ratio%2C%20suggesting%20increased%20mortality%20risk%20with%20advancing%20age.%20%20%0A%20%20%20%20*%20Conversely%2C%20young%20adults%20show%20a%20lower%20hazard%20ratio%2C%20indicating%20a%20reduced%20risk%20relative%20to%20the%20reference%20group.%0A%0A%20%20%20%20**%3Cspan%20style%3D'color%3Abrown'%3EImpact%20of%20Cancer%20Stage%3A%3C%2Fspan%3E**%0A%0A%20%20%20%20*%20Advanced%20cancer%20stages%2C%20particularly%20Stage%20IV%2C%20are%20associated%20with%20markedly%20higher%20hazard%20ratios%2C%20underscoring%20the%20critical%20importance%20of%20early%20detection%20and%20intervention.%0A%0A%20%20%20%20**%3Cspan%20style%3D'color%3Abrown'%3EGenetic%20and%20Biological%20Factors%3A%3C%2Fspan%3E**%0A%0A%20%20%20%20*%20Certain%20genetic%20polymorphisms%20prevalent%20in%20Asian%20populations%2C%20such%20as%20ALDH2%20deficiency%2C%20contribute%20to%20increased%20susceptibility%20to%20cancers%20like%20esophageal%20cancer.%20%20%0A%20%20%20%20%20%20%5BSource%3A%20Wikipedia%20-%20Alcohol%20Flush%20Reaction%5D(https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FAlcohol_flush_reaction)%0A%0A%20%20%20%20*%20Additionally%2C%20variations%20in%20the%20CYP2D6%20gene%20affect%20drug%20metabolism%2C%20potentially%20influencing%20treatment%20efficacy%20and%20outcomes.%20%20%0A%20%20%20%20%20%20%5BSource%3A%20Wikipedia%20-%20CYP2D6%5D(https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FCYP2D6)%0A%20%20%20%20%22%22%22)%0A%0A%0A%20%20%20%20mo.vstack(%5B%0A%20%20%20%20%20%20%20%20mo.ui.tabs(%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20'Hazerdus%20Probabilities'%3A%20hazard_fig%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20'Model%20Summery'%3A%20summery_fig%0A%20%20%20%20%20%20%20%20%7D)%2C%0A%20%20%20%20%20%20%20%20insight%0A%20%20%20%20%5D)%0A%20%20%20%20return%20(%0A%20%20%20%20%20%20%20%20cox_hazerdus_p%2C%0A%20%20%20%20%20%20%20%20cox_summry%2C%0A%20%20%20%20%20%20%20%20cox_summry_numeric%2C%0A%20%20%20%20%20%20%20%20hazard_fig%2C%0A%20%20%20%20%20%20%20%20insight%2C%0A%20%20%20%20%20%20%20%20summery_fig%2C%0A%20%20%20%20)%0A%0A%0Aif%20__name__%20%3D%3D%20%22__main__%22%3A%0A%20%20%20%20app.run()%0A
3c98e2205e19600ddc7f84a8da10191ec646798e6d0b98743934ec6b026d5e17